﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class news_editEPioneerData : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bd();
        }
    }

    void bd()
    {
        CMS.BLL.EPioneerDataBLL bll = new CMS.BLL.EPioneerDataBLL();
        string id = Request["id"];
        string newTypeId = Server.UrlDecode(Request["newsTypeId"]);
        List<CMS.Entity.EPioneerDataModel> list = new List<CMS.Entity.EPioneerDataModel>();
        if (newTypeId == "56" || newTypeId == "54")
        {
            list = bll.GetDataModelPagination(newTypeId, "", id, "", "", 20);
        }
        else if (newTypeId == "0")
        {
            list = bll.GetSTOCKABNORMALMSG(newTypeId, "", id, "", "");
        }
        else if (newTypeId == "0101")
        {
            list = bll.GetNewListWhere(newTypeId, id);
        }
        else
        {
            list = bll.GetNewsTextList("", id, "", "");
        }
        if (list.Count > 0)
            txtTitle.Text = list[0].n_title;
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        CMS.BLL.EPioneerDataBLL bll = new CMS.BLL.EPioneerDataBLL();
        string id = Request["id"];
        string newTypeId = Server.UrlDecode(Request["newsTypeId"]);
        string title = txtTitle.Text.Trim();
        if (!bll.UpdateNews(id, newTypeId, title))
        {
            this.Page.ClientScript.RegisterStartupScript(GetType(), "msg", "<script>alert('更新失败，请重试！');</script>");
            return;
        }
        Response.Redirect("EPioneerData.aspx?newsTypeId=" + newTypeId);
    }
}